package org.example.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.example.domain.User;
import org.example.handler.UserBlockHandler;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
@RefreshScope//配置实时刷新远程
public class UserController {

    @Value("${test}")
    private Long test ;

    @GetMapping("/{id}")
    @SentinelResource(value = "/getUserById" ,
            blockHandler = "getUserById" ,
            blockHandlerClass = UserBlockHandler.class)
    public User getUserById (@PathVariable Long id){
        return User.builder().id(test).name("谌媾觏").intro("大脑壳").build();
    }


}
